﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title class="sub_Title">查看数据源
    </title>
    <meta name="description" content="">
    <meta name="author" content="">

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <!-- #CSS Links -->
    <!-- Basic Styles -->
    <link rel="stylesheet" type="text/css" media="screen" href="css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" media="screen" href="css/font-awesome.css">

    <!-- SmartAdmin Styles : Caution! DO NOT change the order -->
    <link rel="stylesheet" type="text/css" media="screen" href="css/smartadmin-production-plugins.css">
    <link rel="stylesheet" type="text/css" media="screen" href="css/smartadmin-production.css">
    <link rel="stylesheet" type="text/css" media="screen" href="css/smartadmin-skins.css">

    <!-- SmartAdmin RTL Support -->
    <link rel="stylesheet" type="text/css" media="screen" href="css/smartadmin-rtl.css">

    <!-- Demo purpose only: goes with demo.js, you can delete this css when designing your own WebApp -->
    <link rel="stylesheet" type="text/css" media="screen" href="css/demo.css">

    <!-- #FAVICONS -->
    <link rel="shortcut icon" href="img/favicon/favicon.ico" type="image/x-icon">
    <link rel="icon" href="img/favicon/favicon.ico" type="image/x-icon">

    <!-- #GOOGLE FONT -->
    <link rel="stylesheet" href="css/open-sans.css" type="text/css">

    <!-- #APP SCREEN / ICONS -->
    <link rel="apple-touch-icon" href="img/splash/sptouch-icon-iphone.png">
    <link rel="apple-touch-icon" sizes="76x76" href="img/splash/touch-icon-ipad.png">
    <link rel="apple-touch-icon" sizes="120x120" href="img/splash/touch-icon-iphone-retina.png">
    <link rel="apple-touch-icon" sizes="152x152" href="img/splash/touch-icon-ipad-retina.png">

    <!-- iOS web-app metas : hides Safari UI Components and Changes Status Bar Appearance -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">

    <!-- Startup image for web apps -->
    <link rel="apple-touch-startup-image" href="img/splash/ipad-landscape.png"
        media="screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape)">
    <link rel="apple-touch-startup-image" href="img/splash/ipad-portrait.png"
        media="screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait)">
    <link rel="apple-touch-startup-image" href="img/splash/iphone.png" media="screen and (max-device-width: 320px)">
    <link href="appcss/Common.css" rel="stylesheet" />
</head>
<body class="desktop-detected minified">

    <!-- #MAIN PANEL -->
    <div id="main" role="main">

        <!-- RIBBON -->
        <div id="ribbon">

            <span class="ribbon-button-alignment">
                <span class="btn btn-ribbon"><i class="fa fa-home"></i></span>
            </span>

            <!-- breadcrumb -->
            <ol class="breadcrumb">
                <li><a href="DataServiceManagement.html">数据服务管理</a></li>
                <li class="sub_Title">查看数据源</li>
            </ol>
            <!-- end breadcrumb -->

        </div>
        <!-- END RIBBON -->


        <!-- MAIN CONTENT -->
        <div id="content">
            <div class="row hidden">
                <div class="col-xs-12 col-sm-7 col-md-7 col-lg-4">
                    <h1 class="page-title txt-color-blueDark">
                        <i class="fa fa-edit fa-fw "></i>
                        主页
            <span>> 
				查看数据源
            </span>
                    </h1>
                </div>

            </div>

            <!-- widget grid -->
            <section id="widget-grid" class="">

                <!-- row -->
                <div class="row">

                    <!-- NEW WIDGET START -->


                    <!-- NEW WIDGET START -->
                    <article class="col-sm-12 col-md-12 ">

                        <!-- Widget ID (each widget will need unique ID)-->
                        <div class="jarviswidget" id="wid-id-2" data-widget-colorbutton="false"
                            data-widget-editbutton="false">
                            <header>
                                <h2 class="sub_Title">查看数据源</h2>

                            </header>

                            <!-- widget div-->
                            <div>

                                <!-- widget edit box -->
                                <div class="jarviswidget-editbox">
                                    <!-- This area used as dropdown edit box -->

                                </div>
                                <!-- end widget edit box -->

                                <!-- widget content -->
                                <div class="widget-body no-padding">
                                    <form action="" class="smart-form" id="AddDataSource">
                                        <header>数据表单</header>
                                        <fieldset>
                                            <section>
                                                <label class="label">服务名称</label>
                                                <label class="input">
                                                    <input type="text" disabled="disabled" id="ServiceName" />
                                                </label>
                                            </section>
                                        </fieldset>
                                        <fieldset>
                                            <section>
                                                <label class="label">数据源名称</label>
                                                <label class="input">
                                                    <input type="text" name="Name" id="SourceName" class="required" />
                                                </label>
                                            </section>
                                        </fieldset>
                                        <fieldset>

                                            <section>
                                                <label class="label">
                                                    参数列表
                                                </label>

                                                <table class="table table-bordered  table-condensed table-hover smart-form " id="table-details-parameter" style="width: 50%;">
                                                    <thead>
                                                        <tr>
                                                            <th>Name</th>
                                                            <th>Type</th>
                                                            <th>DefaultValue</th>
                                                            <th>Description</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                    </tbody>
                                                </table>
                                            </section>
                                        </fieldset>
                                        <fieldset>

                                            <section>
                                                <label class="label">
                                                    返回结果
                                                </label>

                                                <table class="table table-bordered  table-condensed table-hover smart-form " id="table-details-column" style="width: 50%;">
                                                    <thead>
                                                        <tr>
                                                            <th>Name</th>
                                                            <th>Type</th>
                                                            <th>Description</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                    </tbody>
                                                </table>
                                            </section>
                                        </fieldset>

                                        <footer>
                                            <button type="button" class="btn btn-default" onclick="window.history.back();">
                                                返回
                                            </button>
                                        </footer>
                                    </form>
                                </div>
                                <!-- end widget content -->
                            </div>
                            <!-- end widget div -->
                        </div>
                        <!-- end widget -->
                    </article>
                </div>

                <!-- end row -->

            </section>
        </div>
        <!-- END MAIN CONTENT -->
    </div>

    <!--================================================== -->

    <!-- PACE LOADER - turn this on if you want ajax loading to show (caution: uses lots of memory on iDevices)
<script data-pace-options='{ "restartOnRequestAfter": true }' src="js/plugin/pace/pace.min.js"></script>-->


    <!-- #PLUGINS -->

    <script src="js/libs/jquery-2.1.1.min.js"></script>
    <script src="js/libs/jquery-ui-1.10.3.min.js"></script>
    <!-- BOOTSTRAP JS -->
    <script src="js/bootstrap/bootstrap.min.js"></script>

    <!-- IMPORTANT: APP CONFIG -->
    <script src="js/app.config.js"></script>


    <!-- CUSTOM NOTIFICATION -->
    <script src="js/notification/SmartNotification.min.js"></script>

    <!-- JARVIS WIDGETS -->
    <script src="js/smartwidgets/jarvis.widget.min.js"></script>


    <!-- SPARKLINES -->
    <script src="js/plugin/sparkline/jquery.sparkline.min.js"></script>

    <!-- JQUERY MASKED INPUT -->
    <script src="js/plugin/masked-input/jquery.maskedinput.min.js"></script>


    <!-- JQUERY UI + Bootstrap Slider -->
    <script src="js/plugin/bootstrap-slider/bootstrap-slider.min.js"></script>

    <script src="js/plugin/jquery-validate/jquery.validate.min.js"></script>
    <script src="js/plugin/jquery-validate/jquery.metadata.js"></script>
    <script src="js/plugin/jquery-validate/messages_cn.js"></script>

    <script src="js/app.min.js"></script>
    <script src="appjs/Helper.js"></script>
    <script src="appjs/Common.js"></script>
    <script>
        var ServiceId = GetQueryString("Id");
        var dataSourceId = GetQueryString("dataSourceId");
        $(function () {
            $("#DataServiceId").val(ServiceId);
            getServiceDetails();
            if (dataSourceId != "") {
                $(".sub_Title").html("查看数据源");
                getDataSourceDetails();
                $("#SourceName").attr("disabled", "disabled");
                $("#SourceValue").attr("disabled", "disabled");
                $("#SourceType-2").attr("disabled", "disabled");
                $("#SourceType-1").attr("disabled", "disabled");
            }

        });
        //组合参数数据  编辑时需调用此方法处理返回的数据
        //传入的参数类型为对象数组
        var AppadParameterData = function (data) {
            //var list = new Array();
            var trlist = "";
            for (var i = 0; i < data.length; i++) {
                var $this = data[i];
                //list.push({ name: $this.Name, id: $this.Id, type: $this.Type, description: $this.Description });
                trlist += AssembleParameterData({ name: $this.Name, id: $this.Id, type: $this.Type, description: $this.Description, defaultValue: $this.DefaultValue });
            }
            $("#table-details-parameter").append(trlist);
        }
        //传入参数对象返回一行的表格数据
        var AssembleParameterData = function (data) {
            var tr = "<tr data='" + JSON.stringify(data) + "'><td>";
            tr += (data.name + "</td>");
            tr += ("<td>" + data.type + "</td>");
            tr += ("<td>" + data.defaultValue + "</td>");
            tr += ("<td>" + data.description + "</td>");//备注
            tr += ("</tr>");
            return tr;
        }


        //组合列数据
        //传入的参数类型为对象数组
        var AppadColumnData = function (data) {
            //var list = new Array();
            var trlist = "";
            for (var i = 0; i < data.length; i++) {
                var $this = data[i];
                //list.push({ name: $this.Name, id: $this.Id, type: $this.Type, description: $this.Description });
                trlist += AssembleColumnData({ name: $this.Name, id: $this.Id, type: $this.Type, description: $this.Description });
            }
            $("#table-details-column").append(trlist);
        }
        //传入列对象返回一行的表格数据
        var AssembleColumnData = function (data) {
            var tr = "<tr data='" + JSON.stringify(data) + "'><td>";
            tr += (data.name + "</td>");
            tr += ("<td>" + data.type + "</td>");
            tr += ("<td>" + data.description + "</td>");//备注
            tr += ("</tr>");
            return tr;
        }

        //获取服务的详细信息
        var getServiceDetails = function () {
            $.ajax({
                url: apiUrl,
                data: {
                    "sys:sno": "ETL",
                    "sys:act": "GetDataService",
                    "DataServiceId": ServiceId
                },
                dataType: "json",
                success: function (data) {
                    if (data.IsSccuess) {
                        $("#ServiceName").val(data.Data.Name);
                    } else {
                        if (IsLogined(data.ErrorCode)) {
                            alert(data.Message);
                        }
                    }
                },
                beforeSend: function () {
                    // $("btn_login").html("登录中...");
                }
            });
        }
        //获取数据源信息
        var getDataSourceDetails = function () {
            $.ajax({
                url: apiUrl,
                data: {
                    "sys:sno": "ETL",
                    "sys:act": "GetDataSource",
                    "DataServiceId": ServiceId,
                    "DataSourceId": dataSourceId
                },
                dataType: "json",
                success: function (data) {
                    if (data.IsSccuess) {
                        var str = "";
                        $("#SourceName").val(data.Data.Name);//名称
                        $("#SourceValue").val(data.Data.Value);
                        if (data.Data.Type == 1) {
                            $("#SourceType-1").attr("checked", "checked");
                            $("#SourceType-2").removeAttr("checked");
                        } else {
                            $("#SourceType-2").attr("checked", "checked");
                            $("#SourceType-1").removeAttr("checked");
                        }
                        AppadColumnData(data.Data.Columns);//组装数据并并填充表格
                        AppadParameterData(data.Data.Parameters);//组装数据并并填充表格
                    } else {
                        if (IsLogined(data.ErrorCode)) {
                            alert(data.Message);
                        }
                    }
                },
                beforeSend: function () {
                    // $("btn_login").html("登录中...");
                }
            });
        }

    </script>
</body>
</html>
